As a method of protecting data stored in a memory unit, such as NAND flash memory (hereinafter referred to as NAND memory), there is a method of using an Error Check and Correction code (ECC). According to this method, parity is generated on data by an error-correction coding, and the parity is written on the memory unit together with the data. During a reading process from the memory unit, the parity is read together with the data, and an error correction process is executed. In order to simplify hardware and a process, a size (ECC unit data) of data that is the subject to be protected by using one piece of parity is constant in general.
When the ECC unit data is constant, parity is not generated, if data that is to be written is written on the memory unit without having a data size of the ECC unit data. The data on which the parity is not generated cannot be restored, when error is generated on this data.